package cn.lin.config;

import org.springframework.amqp.support.converter.SimpleMessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.amqp.core.Queue;

import java.util.Arrays;

/**
 * @author cn.Lin
 * @create 2024-12-04-11:43
 */
@Configuration
public class RabbitMQConfig {

    public static final String SIGN_IN_QUEUE = "sign.in.queue";
    private static final String QUICK_QUEUE = "quick.queue";

    @Bean
    public Queue signInQueue(){
        return new Queue(SIGN_IN_QUEUE, true);
    }

    @Bean
    public Queue quickQueue(){
        return new Queue(QUICK_QUEUE, true);
    }

    /**
     * 消息转换器
     * @return
     */
    @Bean
    public SimpleMessageConverter converter() {
        SimpleMessageConverter converter = new SimpleMessageConverter();
        // 示例： com. foo.* 、 *.MyClass
        converter.setAllowedListPatterns(Arrays.asList("*"));
        return converter;
    }
}
